<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:s="http://jboss.com/products/seam/taglib"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich">

	<rich:modalPanel id="lessonEditMD" autosized="true">
		<f:facet name="header">
			<h:outputText value="#{messages['lesson.edit.title']}" />
		</f:facet>
		<a4j:outputPanel>
			<s:fragment rendered="#{lessonsAction.editMode}">
				<a4j:form id="editForm">
					<rich:panel>
						<f:facet name="header">
							<h:outputText value="#{messages['lesson.edit.data']}" />
						</f:facet>
						
						<rich:messages globalOnly="true" />
						<h:panelGrid columns="2">
							<s:decorate template="/template/edit.xhtml">
								<ui:define name="label">#{messages['lesson.edit.name']}</ui:define>
								<h:inputText id="name" value="#{selectedLesson.name}" required="true" />
							</s:decorate>

							<s:decorate template="/template/edit.xhtml">
								<ui:define name="label">#{messages['lesson.edit.note']}</ui:define>
								<h:inputTextarea value="#{selectedLesson.name}" row="3" style="width:100%" />
							</s:decorate>

							<s:decorate template="/template/edit.xhtml">
								<ui:define name="label">#{messages['lesson.edit.voc.typ']}</ui:define>
								<h:selectOneMenu value="#{selectedLesson.vocType}">
									<s:selectItems value="#{vocableTypeList}" var="r" label="#{r.code}">
									</s:selectItems>
								</h:selectOneMenu>
							</s:decorate>
						</h:panelGrid>
					</rich:panel>

					<div class="button_panel">
						<!-- BUTTON - SAVE -->
						<a4j:commandButton value="#{messages['modal.button.save']}"
							action="#{lessonsAction.saveOrUpdate()}"
							oncomplete="if (#{facesContext.maximumSeverity==null}) #{rich:component('lessonEditMD')}.hide();"
							reRender="editForm, lessonGridForm">
						</a4j:commandButton>

						<!-- BUTTON - CANCEL -->
						<a4j:commandButton value="#{messages['modal.button.cancel']}"
							action="#{lessonsAction.endEdit()}"
							onclick="Richfaces.hideModalPanel('lessonEditMD');"
							reRender="lessonGridForm" immediate="true">
						</a4j:commandButton>
					</div>
				</a4j:form>
			</s:fragment>
		</a4j:outputPanel>
	</rich:modalPanel>
</ui:composition>